<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="shortcut icon" href="/chushi/img/favicon.ico" type="image/x-icon" />
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }
        .container {
            width: 100%;
            max-width: 360px;
            margin: 50px auto;
            background-color: #fff;
            padding: 30px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        h2 {
            text-align: center;
            color: #333;
        }
        .error {
            color: red;
            text-align: center;
            margin-bottom: 20px;
            opacity: 1;
            transition: opacity 0.5s ease-in-out;
        }
        .hidden {
            display: none;
            height: 0;
            overflow: hidden;
            margin-bottom: 0;
        }
        form div {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 8px;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            width: 100%;
            padding: 12px 15px;
            border: none;
            background-color: #007bff;
            color: white;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #0056b3;
        }
        .TextMate{
            text-align: center;
        }
    </style>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var errorMessage = document.getElementById('error-message');
            if (errorMessage) {
                setTimeout(function() {
                    errorMessage.classList.add('hidden');
                }, 3000); // Set timeout to 3000 milliseconds (3 seconds)
            }
        });
    </script>
</head>
<body>

<div class="container">
    <header>
        <h2>登录</h2>
    </header>

    <main>
        <form action="Login" method="post">
            <div>
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" required>
            </div>
            <div>
                <label for="password">密码</label>
                <input type="password" id="password" name="password" required>
            </div>
            <%
                String loginError = (String) request.getAttribute("loginError");
                if (loginError != null && !loginError.isEmpty()) {
            %>
            <p id="error-message" class="error"><%= loginError %></p>
            <%
                }
            %>
            <div>
                <button type="submit">登录</button>
            </div>
            <div class="TextMate">没有账号？<a href="/ChuFood/Logup">注册</a> </div>
        </form>
    </main>
</div>

</body>
</html>
